define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'tt/fruit/achieve/index',
                    add_url: 'tt/fruit/achieve/add',
                    edit_url: 'tt/fruit/achieve/edit',
                    del_url: 'tt/fruit/achieve/del',
                    multi_url: 'tt/fruit/achieve/multi',
                    table: 'tt_fruit_achieve',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'login_num', title: __('Login_num')},
                        {field: 'level', title: __('Level')},
                        {field: 'video_num', title: __('Video_num')},
                        {field: 'weapon_1', title: __('Weapon_1')},
                        {field: 'weapon_2', title: __('Weapon_2')},
                        {field: 'share_num', title: __('Share_num')},
                        {field: 'one_cut_num', title: __('One_cut_num')},
                        {field: 'lucky_wheel_num', title: __('Lucky_wheel_num')},
                        {field: 'fruit_1', title: __('Fruit_1')},
                        {field: 'fruit_2', title: __('Fruit_2')},
                        {field: 'fruit_3', title: __('Fruit_3')},
                        {field: 'fruit_4', title: __('Fruit_4')},
                        {field: 'fruit_5', title: __('Fruit_5')},
                        {field: 'fruit_6', title: __('Fruit_6')},
                        {field: 'fruit_7', title: __('Fruit_7')},
                        {field: 'fruit_8', title: __('Fruit_8')},
                        {field: 'fruit_9', title: __('Fruit_9')},
                        {field: 'fruit_10', title: __('Fruit_10')},
                        {field: 'fruit_11', title: __('Fruit_11')},
                        {field: 'fruit_12', title: __('Fruit_12')},
                        {field: 'fruit_13', title: __('Fruit_13')},
                        {field: 'fruit_14', title: __('Fruit_14')},
                        {field: 'fruit_15', title: __('Fruit_15')},
                        {field: 'fruit_16', title: __('Fruit_16')},
                        {field: 'fruit_17', title: __('Fruit_17')},
                        {field: 'fruit_18', title: __('Fruit_18')},
                        {field: 'fruit_19', title: __('Fruit_19')},
                        {field: 'fruit_20', title: __('Fruit_20')},
                        {field: 'fruit_21', title: __('Fruit_21')},
                        {field: 'fruit_22', title: __('Fruit_22')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});